package com.ukit.weather_xml.Other.DataManger

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query

@Dao
interface WeatherDao {
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertSettings(settings: Settings)

    @Query("SELECT * FROM settings")
    suspend fun getSettings(): Settings?

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertWeatherData(weatherData: WeatherData)

    @Query("SELECT * FROM weather_data WHERE city = :city ORDER BY timestamp DESC LIMIT 1")
    suspend fun getLastWeatherData(city: String): WeatherData?

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertUserCity(userCity: UserCity)

    @Query("SELECT * FROM user_cities")
    suspend fun getUserCities(): List<UserCity>
}
